package com.chucang.shucang.ttp.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/9/26 21:26
 * @description 腾讯短信
 */
@Configuration
public class TencentSmsConfig {

    @Value("${tencent.sms.endPoint}")
    private String endPoint;

    @Value("${tencent.sms.region}")
    private String region;

    @Value("${tencent.sms.secretId}")
    private String secretId;

    @Value("${tencent.sms.secretKey}")
    private String secretKey;

    @Bean
    public SmsClient smsClient() {
        Credential cred = new Credential(secretId, secretKey);
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint(endPoint);
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        return new SmsClient(cred, region, clientProfile);
    }

}
